/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.BUS;

import Server.DTO.Query;

/**
 *
 * @author Trung
 */
public class QueryUlti {
        
    public static String checkQueryType(String queryString)
    {
        if(queryString.startsWith("SELECT"))//Select query
        {
            if(queryString.indexOf("WHERE") != -1)
                return "SELECT_HAVEWHERE";
            else
                return "SELECT_NOWHERE";
        }
        else
        {
            if(queryString.startsWith("INSERT"))//Insert query
                return "INSERT";
            else
            {
                if(queryString.startsWith("DELETE"))//Delete query
                {
                    if(queryString.indexOf("WHERE") != -1)
                        return "DELETE_HAVEWHERE";
                    else 
                        return "DELETE_NOWHERE";
                }
                else
                {
                    if(queryString.startsWith("UPDATE"))//Update query
                    {
                        if(queryString.indexOf("WHERE") != -1)
                            return "UPDATE_HAVEWHERE";
                        else 
                            return "UPDATE_NOWHERE";
                    }
                    else //InvalidQuery
                        return "INVALID_QUERY";
                }
            }
        }
    }
    
}
